from manimlib import *
from numpy import flip, insert

LV,QL,QH,JH='#75cfb8','#bbdfc8','#f0e5d8','#ffc478'

class p1(Scene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        a,b,c=[-4,-3,0],[4,-3,0],[1,3,0]
        ab,ac,bc=Line(a,b),Line(a,c),Line(b,c)
        tri=VGroup(ab,ac,bc)
        m,n=[-1,0.6,0],[2.5,0,0]
        an,bm=Line(a,n),Line(b,m)
        self.add(tri,an,bm,
            Tex('2').move_to([2.5,-1,0]),
            Tex('3').move_to([-1,-1,0]),
            Tex('4').move_to([0.5,-2,0]),
            Tex('?').move_to([1,1,0])
        )
        self.wait()

class p2(Scene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        a,b,c=[-4,-3,0],[4,-3,0],[1,3,0]
        ab,ac,bc=Line(a,b),Line(a,c),Line(b,c)
        tri=VGroup(ab,ac,bc)
        m,n=[-1,0.6,0],[2.5,0,0]
        an,bm=Line(a,n),Line(b,m)
        self.add(tri,an,bm,
            Tex('2').move_to([2.5,-1,0]),
            Tex('3').move_to([-1,-1,0]),
            Tex('4').move_to([0.5,-2,0]),
        )
        # p2
        p=line_intersection(an.get_start_and_end(),bm.get_start_and_end())
        cp=Line(c,p)
        self.add(cp,
            Tex('x').move_to([0.2,1,0]),
            Tex('y').move_to([1.5,1,0]),
            Tex('A').next_to(a,DL),
            Tex('B').next_to(b,DR),
            Tex('C').next_to(c),
            Tex('M').next_to(m,LEFT),
            Tex('N').next_to(n),
            Tex('P').next_to(p,DOWN)
        )
        self.wait()

class p1(Scene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        width=6
        height=6
        a,b,c,d=[-width/2,height/2,0],[width/2,height/2,0],[width/2,-height/2,0],[-width/2,-height/2,0]
        e=[0,-height/2,0]
        ac,be=Line(a,c),Line(b,e)
        f=line_intersection(ac.get_start_and_end(),be.get_start_and_end())
        abcd=Polygon(a,b,c,d)
        self.add(abcd,ac,be,
            Tex('A').next_to(a,UL),
            Tex('B').next_to(b,UR),
            Tex('C').next_to(c,DR),
            Tex('D').next_to(d,DL),
            Tex('E').next_to(e,DOWN),
            Tex('F').next_to(f)
        )
        self.wait()